import java.util.*;

/**
 * 子串分值
 */
public class SubstringScoreTrue {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        String str = scan.nextLine();
        long len = str.length();
        char[] arr = str.toCharArray();
        System.out.println(getPartFen(arr, len));
        scan.close();
    }

    private static long getPartFen(char[] arr, long len) {
        long sum = 0;
        int left, right;
        for (int i = 0; i < len; i++) {
            char c = arr[i];
            for (left = i - 1; left >= 0; left--) {
                if (c == arr[left]) {
                    break;
                }
            }
            for (right = i + 1; right < len; right++) {
                if (c == arr[right]) {
                    break;
                }
            }
            sum += (long) (right - i) * (i - left);
        }
        return sum;
    }
}
